/**
 * Copyright (c) 2011 - 2012, Sohu Inc. All rights reserved.
 * @fileoverview Sohu  灵感管理页审核功能
 * @author  wangxin | xinwang200110@sohu-inc.com
 * @version 1.0 | 2013-04-17
 * @param
 * @example
 */
$require('mod.cPrompt');
$require('mod.cAlert');


LJS.define('cpt.inspect', function(ljs){
    var that = {};
    function sendRequest(data){
        $.ajax({
            url: '/jianbao/set_check',
			//url: 'test1.txt',
            data: {
                ids: data
            },
            type: 'POST',
            dataType: 'json',
            cache: false,
            success: function(json){
                that.layer.del();
                that.layer = null;
                if (json.status == '100000') {
                    ljs.mod.cAlert({
                        tpl: '<div class="inforPop"><div class="title"><span class="btnExit"><a href="javascript:void(0);"></a></span></div><div class="txtGod"><span>审核成功!</span></div></div>',
                        caClose: true,
                        btnTxt: '确定'
                    });
                    var setT = window.setTimeout(function(){
                        setT = null;
                        window.location.reload();
                    }, 2000);
                }else if(json.status=='100003'){
                	window.location.href = json.content.url;
                }
                else {
                    alert(json.msg);
                }
            },
            error: function(){
                that.layer.del();
                that.layer = null;
                alert('数据加载失败');
            }
        });
    }
    function addEvt(){
        that.box.delegate('a[button-type="check"]', 'click', function(e){
            e = e || window.event;
            var target = e.target || e.srcElement;
            var id = target.getAttribute('data');
            that.layer = ljs.mod.cPrompt({
                tpl: '<div class="infor"><div class="title"><span class="txt">信息提示</span><span class="btnExit"><a href="javascript:void(0);" event_type="del"></a></span></div><dl class="conTxt"><dt><span>您确定要通过该审核吗？</span></dt>\
                <dd><span class="colorRem">通过后将不可恢复~</span></dd></dl><div class="btnEn"><a class="btn-et" href="javascript:void(0);" event_type="ok"><span>确定</span></a><a class="btn-ex" href="javascript:void(0);" event_type="del"><span>取消</span></a></div></div>',
                caClose: true,
                txt: '',
                btnTxt: '确定',
                fun: function(){
                    sendRequest(id);
                }
            });
        });
    }
    that.init = function(){
        that.box = $('#list');
        addEvt();
    }
    return that;
});
